import {Ref} from "vue";
import {IStoreGoodsPageRow} from "@/api/modules/pointsMall";

export function useGoodsSelect(){
  const router = useRouter()
  const isShowSelectGoods: Ref<boolean> = ref(false)

  const showGoodSelect = () => {
    isShowSelectGoods.value = true
  }

  const handleSelect = (rowData: IStoreGoodsPageRow) => {
    // console.log('rowData', rowData)
    router.push({
      path: 'configure_goods',
      query: {
        id: rowData.id
      }
    })
  }

  const selectForm = reactive({
    name: '',
    storeIds: [],
    withProducts: true,
    defaultStore:0,
    categoryId:'',
    minCost:null,
    maxCost:null
  })

  return {
    isShowSelectGoods,
    showGoodSelect,
    selectForm,
    handleSelect,
  }
}
